<?php
namespace app\index\controller;

use app\index\model\Messages as Ma;
use think\Request;
class MessageController extends BaseController{
	private $foot;
	public function _initialize(){
		$this->foot=$this->foot();
	}
	public function index(){
		if($this->request->isGet() ){
			$this->assign([
			'foot'=>$this->foot
			]);
			return $this->fetch();
		}
		if($this->request->isPost() ){
			$params=$this->request->except('/index/message/index_html');
			var_dump($params);
			if( (new Ma($params) )->allowField(true)->save() ){
				$this->redirect(url('index/message/suc'));
			}else{
				$this->error('提交有误,谢谢您的建议!,请重新提交');
			}
		}
		
	}
	//提交成功
	//
	public function suc(){
		$this->assign([
			'foot'=>$this->foot
		]);
		return $this->fetch();
	}
}